<?php
namespace App\Goods\Models;

use App\BaseModel;
use Illuminate\Database\Eloquent\SoftDeletes;

class GoodsAttr extends BaseModel
{
    use softDeletes;

    protected $table ="zwj_crm_goods_attrs";

    protected $guarded = [];

    protected $appends = [
        'type_name'
    ];

    /**
     * 类型查询器
     * @param $value
     * @return string
     */
    public function getTypeNameAttribute($value)
    {
        $name = [
            1 => '文本',
            2 => '单选',
            3 => '多选'
        ];
        return isset($name[$this->type]) ? $name[$this->type] : '未知';
    }
}
